﻿using ET.Monitor.DAL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ET.Monitor.Model
{
    public class XmlModel
    {
        string fileID = ""; string filePath = "";
        string role = "", name = "", link = "", icon = "";
        byte[] btXml = null; 
        int order = 0;
        XmlDAL xd = new XmlDAL();
        public XmlModel(string rl, string nm, string lk, string ic, int od)
        {
            role = rl;
            name = nm;
            link = lk;
            icon = ic;
            order = od;
        }

        public XmlModel(string FileId) { fileID = FileId; }
        public XmlModel(string FileId, string FilePath) { fileID = FileId; filePath = FilePath; }
        public XmlModel(string FileId, byte[] FileXml) { fileID = FileId; btXml = FileXml; }

        public bool IsEmptyXml
        {
            get { return xd.IsEmptyXml(fileID); }
        }

        public bool DownLoadXml
        {
            get { return xd.DownLoadXml(fileID, filePath); }
        }

        public DataTable GetFileXml
        {
            get { return xd.GetXmlFile(fileID); }
        }

        public bool UpLoadXml
        {
            get { return xd.UpLoadXml(fileID, btXml); }
        }

        #region Page
        bool isPage;

        public bool IsPage
        {
            get { return xd.AddPage(role, order, icon, name, link); }
            set { isPage = value; }
        }
        #endregion

        #region dtPage
        DataTable dtPage;

        public DataTable DtPage
        {
            get { return xd.GetPage(fileID); }
            set { dtPage = value; }
        }
        #endregion

        #region Del Page
        bool delpage;

        public bool Delpage
        {
            get { return xd.DelPage(fileID, filePath); }
            set { delpage = value; }
        }
        #endregion

        #region checkLink
        object checkLink;

        public object CheckLink
        {
            get { return xd.CheckLink(fileID, filePath); }
            set { checkLink = value; }
        }
        #endregion
    }
}
